<?php
	/*
	 * This file is part of phpitter.
 	 * 
	 * phpitter is free software: you can redistribute it and/or modify
	 * it under the terms of the GNU General Public License as published by
	 * the Free Software Foundation, either version 3 of the License, or
	 * (at your option) any later version.
 	 * 
	 * phpitter is distributed in the hope that it will be useful,
	 * but WITHOUT ANY WARRANTY; without even the implied warranty of
	 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	 * GNU General Public License for more details.
 	 * 
	 * You should have received a copy of the GNU General Public License
	 * along with phpitter.  If not, see <http://www.gnu.org/licenses/>.
	 *
	 * Copyright 2008 Ryan Hadley
	 */

	function libNotifyNotice($updates)
	{
		if ( count($updates) < 5 )
		{
			foreach($updates as $tweet)
			{
				$summary = $tweet['user']['name'];
				$body = html_entity_decode($tweet['text']);
				$icon = '~/phpitter/' . $tweet['user']['local_image'];

				exec("/usr/bin/notify-send -i $icon " . escapeshellarg($summary) . " " . escapeshellarg($body));
			}
		} else {
			$summary = 'New Tweets';
			$body = 'Received ' . count($updates) . ' updates.';
			exec("/usr/bin/notify-send " . escapeshellarg($summary) . " " . escapeshellarg($body));
		}
	}

	$pluggable->registerNewUpdatesCallback('libNotifyNotice');
?>
